package icom.icss.controller;

import icom.icss.entity.User;
import icom.icss.service.impl.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet(name = "SelectServlet",urlPatterns = {"/select"})
public class SelectServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String username = request.getParameter("username");
        String count = request.getParameter("count");

        UserServiceImpl userService = new UserServiceImpl();
        User  user=null;
        try {
             user = userService.selectUsername(username);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        request.setAttribute("user" ,user);
        request.setAttribute("count",count);
        request.getRequestDispatcher("edit.jsp").forward(request,response);


    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
         doPost(request,response);
    }
}
